
using System.Collections.Generic;
using UnityEngine;

public class GiftCode : MonoBehaviour
{
    public static GiftCode instance;

    private void Awake()
    {
        instance=this;
    }

    //礼包码
    public List<string> codes = new List<string>();
    //是否已经获取
    public List<bool> isGetList = new List<bool>();

    //对比礼品码
    public void MathCode(string str)
    {
        bool flag = false;
        if (str==codes[0])
        {
            if (isGetList[0])
            {
                TipSayManager.Instance.Say("礼品<color=red> 已经获取 </color>");
                return;
            }
            isGetList[0]=true;
            GetArtifact();
            flag=true;
        }
        else if (str==codes[1])
        {
            if (isGetList[1])
            {
                TipSayManager.Instance.Say("礼品<color=red> 已经获取 </color>");
                return;
            }
            isGetList[1]=true;
            GetTurn();
            flag=true;
        }
        else if (str==codes[2])
        {
            if (isGetList[2])
            {
                TipSayManager.Instance.Say("礼品<color=red> 已经获取 </color>");
                return;
            }
            isGetList[2]=true;
            GetDamageArmorHpMidle();
            flag=true;
        }
        else if (str==codes[3])
        {
            if (isGetList[3])
            {
                TipSayManager.Instance.Say("礼品<color=red> 已经获取 </color>");
                return;
            }
            isGetList[3]=true;
            GetDamageArmorHpMore();
            flag=true;
        }
        else if (str==codes[4])
        {
            if (isGetList[4])
            {
                TipSayManager.Instance.Say("礼品<color=red> 已经获取 </color>");
                return;
            }
            isGetList[4]=true;
            GetKey();
            flag=true;
        }
        else if (str==codes[5])
        {
            if (isGetList[5])
            {
                TipSayManager.Instance.Say("礼品<color=red> 已经获取 </color>");
                return;
            }
            isGetList[5]=true;
            GetCoin();
            flag=true;
        }
        else if (str==codes[6])
        {
            if (isGetList[6])
            {
                TipSayManager.Instance.Say("礼品<color=red> 已经获取 </color>");
                return;
            }
            isGetList[6]=true;
            OpenBloodMoon();
            flag=true;
        }
        if (flag)
        {
            //礼品码正确
            TipSayManager.Instance.Say("礼品码<color=yellow> 正确 </color>");
        }
        else
        {
            //礼品码错误
            TipSayManager.Instance.Say("礼品码<color=red> 错误 </color>");
        }
    }
    //获取神器
    public void GetArtifact()
    {
        foreach(var i in ArtifactManager.instance.data)
        {
            ArtifactManager.instance.AddArtifact(i.myName);
        }
    }
    //获取符咒
    public void GetTurn()
    {
        foreach(var i in TurnManager.instance.datas)
        {
            TurnManager.instance.AddTurn(i.myName);
        }
    }
    //获取防御和攻击和血量666
    public void GetDamageArmorHpMore()
    {
        GameManager.Instance.ChangePlayerHp(6666);
        GameManager.Instance.ChangeDamage(666);
        GameManager.Instance.ChangeArmor(666);
    }
    //获取防御和攻击和血量66
    public void GetDamageArmorHpMidle()
    {
        GameManager.Instance.ChangePlayerHp(666);
        GameManager.Instance.ChangeDamage(66);
        GameManager.Instance.ChangeArmor(66);
    }
    //获取Key
    public void GetKey()
    {
        GameManager.Instance.AddKey(10, "黄色");
        GameManager.Instance.AddKey(10, "蓝色");
        GameManager.Instance.AddKey(10, "红色");
    }
    //金币
    public void GetCoin()
    {
        GameManager.Instance.AddCoin(66);
    }
    //开启血月
    public void OpenBloodMoon()
    {
        BloodOfMoonEvent.instance.OpenBloodOfMoon();
    }
}
